package cn.cloud.project.consumer.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("index")
@Tag(name = "首页")
public class IndexController {

    @Operation(summary = "向客人问好")
    @Parameter(name = "name", description = "姓名", in = ParameterIn.QUERY)
    @GetMapping("/hello")
    public String sayHi(@RequestParam String name) {
        return "Hi:" + name;
    }


    @Operation(summary = "测试参数可以为空")
    @Parameters({
            @Parameter(name = "name", description = "姓名", in = ParameterIn.QUERY)
    })
    @GetMapping("/nullable")
    public String testNullable(String name) {
        return "Hi:" + name;
    }

}